#CROSS=mipsel-linux-

P4P_SUPPORT := 1

CFLAGS = -fpermissive -I../include -I./minilzo -I.
CPPFALGS = -fpermissive -I../include -I./minilzo -I.
SOURCES = $(wildcard platform/linux/*.cpp) $(wildcard minilzo/*.cpp) $(wildcard *.cpp)
DEP = $(wildcard *.h)
OBJS = $(patsubst %.cpp, objs/%.o, $(SOURCES))

CROSS_DEF = $(subst -,_,$(CROSS))

CFLAGS += -m32 
CXXFLAGS += -m32 
LDFLAGS += -m32

CC=$(CROSS)gcc
AR=$(CROSS)ar
STRIP=$(CROSS)strip

TARGET =$(CROSS)libfpsensor_commpro.so

CDIR=$(shell pwd)

DEBUG = -DDEBUG

all: $(TARGET)
	@echo "build all ok"

$(OBJS): objs/$(CROSS)%.o: %.cpp $(DEP) 
	if [ ! -d objs ]; then mkdir -p objs; fi;
	if [ ! -d objs/platform/linux/ ]; then mkdir -p objs/platform/linux; fi;
	if [ ! -d objs/minizlo ]; then mkdir -p objs/minilzo; fi;
	$(CC) -O2 $(CFLAGS) $(DEGUG) -fPIC -c $< -o $@
$(TARGET): $(OBJS)
	$(CC) $(LDFLAGS) -shared -fPIC -o $@ $(OBJS) 
	$(STRIP) $(TARGET)
	-mkdir -p ../libs
	cp $(TARGET) ../libs
	cp -r platform/linux/libs/* ../libs
	rm $(TARGET)
dtest: $(OBJS)
	$(CC) -o $@ $(OBJS)

clean:
	rm -rf *~ *.swp *.so objs

